let a: string;

let b: boolean | number;

let c: "male" | "female";

let d: any;

// 类型转换
let e: unknown = "Hello,World!";
a = e as string;
a = <string>e;

// 声明含有指定属性的对象
let f1: {name: string, age?: number};
let f2: object;
// 通用对象类型的声明
let f3: {[propName: string]: any};

let g: (n1: number, n2: number) => number;
g = (n1, n2) => {
    return n1 + n2;
}

// 数组
let h1: string[];
let h2: Array<string>;

// 元组
let i: [string, number];

// 枚举
enum Gender {
    Male, Female
}

// 类
class User {
    name: string;
    age: number;
    gender?: Gender;
}

// 接口
interface Animal {
    type: number;
    eat: (type: number) => void;
}

// 定义类型别名
type counter = 1 | 2 | 3 | 4 | 5;
let j: counter;